package com.briup.jz.web.controller;

import java.util.List;

import javax.validation.constraints.NotNull;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.briup.jz.bean.Order;
import com.briup.jz.service.IOrderService;
import com.briup.jz.utils.Message;
import com.briup.jz.utils.MessageUtil;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

@Api(description = "订单管理相关接口")
@Validated
@RestController
@RequestMapping("/ord1010er")
public class OrderController {

	@Autowired
	private IOrderService orderService;

	@ApiOperation(value = "查询所有订单信息")
	@GetMapping("query")
	public Message query(Long id) {
		List<Order> list = orderService.query(id);
		return MessageUtil.success(list);
	}

	@ApiOperation(value = "通过id删除")
	@GetMapping("deleteById")
	@ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "主键", paramType = "query", required = true), })
	public Message deleteById(@NotNull Long id,String status,Long employeeId) {

		orderService.deleteById(id);
		return MessageUtil.success("删除成功");
	}

	@ApiOperation(value = "保存或更新订单信息")
	@ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "主键", paramType = "form"),
			@ApiImplicitParam(name = "orderTime", value = "订单时间", paramType = "form"),
			@ApiImplicitParam(name = "serviceTime", value = "服务时间", paramType = "form"),
			@ApiImplicitParam(name = "total", value = "订单数量", paramType = "form"),
			@ApiImplicitParam(name = "status", value = "订单状态", paramType = "form"),
			@ApiImplicitParam(name = "remark", value = "订单评价", paramType = "form"),
			@ApiImplicitParam(name = "customerId", value = "顾客id", paramType = "form"),
			@ApiImplicitParam(name = "addressId", value = "地址id", paramType = "form"),
			@ApiImplicitParam(name = "employeeId", value = "员工id", paramType = "form"), })
	@PostMapping("saveOrUpdate")
	public Message saveOrUpdate(Order order) {
		orderService.saveOrUpdate(order);
		return MessageUtil.success("更新成功");
	}

	@GetMapping("cancelSendOrder")
	@ApiOperation(value = "取消派单")
	@ApiImplicitParam(name = "orderId", value = "orderId", paramType = "query")
	public Message cancelSendOrder(Long orderId) {
		return null;
	}

	@GetMapping("confirmOrder")
	@ApiOperation(value = "确认订单")
	@ApiImplicitParam(name = "orderId", value = "orderId")
	public Message confirmOrder(Long orderId) {
		return null;
	}

	@GetMapping("findById")
	@ApiOperation(value = "查询订单")
	@ApiImplicitParam(name = "id", value = "id")
	public Message findById(Long id) {

		return null;
	}

	@GetMapping("rejectOrder")
	@ApiOperation(value = "拒绝订单")
	@ApiImplicitParam(name = "orderId", value = "orderId")
	public Message rejectOrder(Long orderId) {

		return null;
	}

	@GetMapping("sendOrder")
	@ApiOperation(value = "派单")
	@ApiImplicitParams({ @ApiImplicitParam(name = "waiterId", value = "waiterId", paramType = "query"),
			@ApiImplicitParam(name = "orderId", value = "orderId", paramType = "query") })
	public Message sendOrder(Long waiterId, Long orderId) {

		return null;
	}

	@GetMapping("serviceCompleteOrder")
	@ApiOperation("員工服務結束")
	@ApiImplicitParam(name = "orderId", value = "orderId", paramType = "query")
	public Message serviceCompleteOrder(Long orderId) {

		return null;
	}

	@GetMapping("takeOrder")
	@ApiOperation("接單")
	@ApiImplicitParam(name = "orderId", value = "orderId", paramType = "query")
	public Message takeOrder(Long orderId) {

		return null;
	}

	@PostMapping("submitOrder")
	@ApiOperation("提交订单")
    @ApiImplicitParams({
        @ApiImplicitParam(name="id",value = "订单id",paramType = "form"),
        @ApiImplicitParam(name="orderTime",value = "订单时间",paramType = "form"),
        @ApiImplicitParam(name="serviceTime",value = "服务时间",paramType = "form"),
        @ApiImplicitParam(name="total",value = "费用",paramType = "form",required = true),
        @ApiImplicitParam(name="status",value = "状态",paramType = "form"),
        @ApiImplicitParam(name="remark",value = "标注",paramType = "form"),
        @ApiImplicitParam(name="customerId",value = "顾客编号",paramType = "form",required = true),
        @ApiImplicitParam(name="addressId",value = "地址编号",paramType = "form",required = true),
        @ApiImplicitParam(name="employeeId",value = "员工编号",paramType = "form")
    })
	public Message submitOrder(Order order) {
		orderService.submitOrder(order);
		return MessageUtil.success("提交成功");
	}

}